<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return['systemxieyi']=$this->plugin_setting('systemxieyi');
if($_RQ['op']=='get'){
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),array('qq','wechat','nickname','avatar','birth','pcd','mobile','address'));
	$item = pdo_get('jy_wuliu_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if(!$item){
		exi('找不到会员信息！','error');
	}
	if($item['pcd']){
		$item['pcd']=json_decode($item['pcd'],true);
	}else{
	   $item['pcd']=array('province'=>''); 
	}
	$item['xianlus']=$item['xianlus']?json_decode($item['xianlus'],true):array(array('fromcity'=>'','tocity'=>''));
	$item['images']=json_decode($item['images'],true);
	$item['lat_lng']=json_decode($item['lat_lng'],true);
	$item['pcd']=json_decode($item['pcd'],true);
	$item['title'] = $item['title']?$item['title']:$member['nickname'];
	$item['mobile'] = $item['mobile']?$item['mobile']:$member['mobile'];
	$item['wechat'] = $item['wechat']?$item['wechat']:$member['wechat'];
	$item['avatar'] = tomedia($member['avatar']);
	$item['address'] = $item['address']?$item['address']:$member['address'];
	$return['item']=$item;
	$return['province']=cfc('tools')->pcd();
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if(!$postdata['checked']){
			exi('请先阅读协议！','error');
	}
	if(!$postdata['title']){
			exi('商户名称不能为空！','error');
	}
	if(!$postdata['mobile']){
			exi('联系电话不能为空！','error');
	}
	$member_update=array(
		'mobile'=>trim($postdata['mobile']),
	);
	if($postdata['wechat']){
		$member_update['wechat']=trim($postdata['wechat']);
	}
	model('core/member')->member_update($_SESSION['uid'],$member_update);
	$postdata['pcd']=$postdata['pcd']?ijson_encode($postdata['pcd']):'{"广东","深圳","龙华"}';
	$postdata['lat_lng']=ijson_encode($postdata['lat_lng']);
	$postdata['images']=ijson_encode($postdata['images']);
	$postdata['xianlus']=ijson_encode($postdata['xianlus']);
	$fields=array('title','logo','desc','pcd','lat_lng','chepai','cheimg','zhizhao','zhuanxianimg','wprice1','wprice2','vprice1','vprice2','jprice','images','xianlus','mobile','address');
	$data=array_fields($fields,$postdata);
	pdo_update('jy_wuliu_member',$data,array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	exi('设置成功！','','goback');
}